﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace MsgCenter.Service.Helper
{
    public class LogServiceHelper
    {
        public static readonly log4net.ILog loginfo_syncdata = log4net.LogManager.GetLogger("loginfo_syncdata");      //选择<logger name="loginfo">的配置 
        public static readonly log4net.ILog logerror_syncdata = log4net.LogManager.GetLogger("logerror_syncdata");     //选择<logger name="logerror">的配置

        public static readonly log4net.ILog loginfo_message = log4net.LogManager.GetLogger("loginfo_message");      //选择<logger name="loginfo">的配置 
        public static readonly log4net.ILog logerror_message = log4net.LogManager.GetLogger("logerror_message");     //选择<logger name="logerror">的配置

        public static void SetConfig()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        public static void SetConfig(FileInfo configFile)
        {
            log4net.Config.XmlConfigurator.Configure(configFile);
        }
        /// <summary>
        /// 数据同步日志
        /// </summary>
        /// <param name="info"></param>
        public static void WriteSyncDataLog(string info)
        {
            if (loginfo_syncdata.IsInfoEnabled)
            {
                loginfo_syncdata.Info(info);
            }
        }
        /// <summary>
        /// 数据同步错误日志
        /// </summary>
        /// <param name="info"></param>
        /// <param name="se"></param>
        public static void WriteSyncDataError(string info, Exception se)
        {
            if (logerror_syncdata.IsErrorEnabled)
            {
                logerror_syncdata.Error(info, se);
            }
        }

        /// <summary>
        /// 数据同步错误日志
        /// </summary>
        /// <param name="info"></param>
        public static void WriteSyncDataError(string info)
        {
            if (logerror_syncdata.IsErrorEnabled)
            {
                logerror_syncdata.Error(info);
            }
        }


        /// <summary>
        /// 短信服务日志
        /// </summary>
        /// <param name="info"></param>
        public static void WriteMessageLog(string info)
        {
            if (loginfo_message.IsInfoEnabled)
            {
                loginfo_message.Info(info);
            }
        }
        /// <summary>
        /// 短信服务错误日志
        /// </summary>
        /// <param name="info"></param>
        /// <param name="se"></param>
        public static void WriteMessageError(string info, Exception se)
        {
            if (logerror_message.IsErrorEnabled)
            {
                logerror_message.Error(info, se);
            }
        }
        /// <summary>
        /// 短信服务错误日志
        /// </summary>
        /// <param name="info"></param>
        public static void WriteMessageError(string info)
        {
            if (logerror_message.IsErrorEnabled)
            {
                logerror_message.Error(info);
            }
        }
    }
}

